import java.util.*;
import java.io.* ;

// kanan和高音
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Mainkanan 
{
     static Read in = new Read() ;
     static PrintWriter out = new PrintWriter(
        new BufferedWriter(new OutputStreamWriter(System.out))
     );

    public static void main(String[] args) throws IOException{
        int n = in.nextInt() ;
        int[] arr = new int[n] ; 
        int len = 0 ; 
        for(int i=0 ; i < n ; i ++){
            arr[i] = in.nextInt() ;
        }
        int max = 1 ;
        int ret = 1 ;
        for(int i=1 ; i < n ; i ++){
            while(i < n && Math.abs(arr[i]-arr[i-1]) <= 8){
              ret ++;
             i ++;
            }
            max = Math.max(max , ret) ; 
        }


        out.println(max) ; 
        out.close() ;
    }
}

//class Read{
//    StringTokenizer st = new StringTokenizer("") ;
//    BufferedReader bf = new BufferedReader(
//        new InputStreamReader(System.in)
//    );
//    String next() throws IOException{
//        while(!st.hasMoreTokens()){
//            st = new StringTokenizer(bf.readLine()) ;
//        }
//        return st.nextToken() ;
//    }
//    int nextInt()  throws IOException{
//        return Integer.parseInt(next()) ;
//    }
//
//}